{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3df6ea05",
   "metadata": {},
   "source": [
    "# Best Quadratic Approximation"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9f3501a1",
   "metadata": {},
   "source": [
    "## Normal Equation\n",
    "> best quadratic approximation problem\n",
    "$$\n",
    "    ||f-S^*||^2_2 = \\mathop{inf}\\limits_{S \\in \\varphi}||f-S||^2_2 = \\mathop{inf}\\limits_{S \\in \\varphi}\\displaystyle\\int_a^b{\\rho(x){[f(x)-S(x)]}^2}dx\n",
    "$$\n",
    "\n",
    "$$\n",
    "    S(x) = \\displaystyle\\sum_{j=0}^{n}{a_j\\varphi_j(x)}\n",
    "$$\n",
    "\n",
    "> convex function extremum deduction\n",
    "\n",
    "$$\n",
    "    I(a_0, a_1, \\cdots, a_n) = \\int_a^b{\\rho(x)[\\displaystyle\\sum_{j=0}^{n}{a_j\\varphi_j(x)-f(x)}]^2dx}\n",
    "$$\n",
    "\n",
    "> let first order derivitive equals to 0\n",
    "\n",
    "$$\n",
    "    \\frac{\\partial I}{\\partial a_k} = 2\\displaystyle\\int_a^b{\\rho(x)[\\displaystyle\\sum_{j=0}^{n}{a_j\\varphi_j(x)-f(x)}]}\\varphi_k(x)dx = 0\\space\\space,\\space\\space (k=0,1,2,\\cdots,n)\n",
    "$$\n",
    "\n",
    "> we get normal equation, which could calculate our parameter vector ${a_k}$\n",
    "\n",
    "$$\n",
    "    \\displaystyle\\sum_{j=0}^{n}{(\\varphi_k,\\varphi_j)a_j} = (f,\\varphi_k)\\space\\space,\\space\\space (k=0,1,2,\\cdots,n)\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f1dafc38",
   "metadata": {},
   "source": [
    "## Hilbert Matrix\n",
    "> inner product matrix of each term in a series of polynomial\n",
    "\n",
    "$$\n",
    "\\mathbf{H} = \n",
    "\\begin{bmatrix}\n",
    "(\\varphi_0,\\varphi_0) & (\\varphi_0,\\varphi_1) & \\cdots & (\\varphi_0,\\varphi_n) \\\\\n",
    "(\\varphi_1,\\varphi_0) & (\\varphi_1,\\varphi_1) & \\cdots & (\\varphi_1,\\varphi_n) \\\\\n",
    "\\vdots & \\vdots & \\ddots & \\vdots \\\\\n",
    "(\\varphi_n,\\varphi_0) & (\\varphi_n,\\varphi_1) & \\cdots & (\\varphi_n,\\varphi_n) \\\\\n",
    "\\end{bmatrix}\n",
    "$$\n",
    "\n",
    "> the matrix form of calculation should be like:\n",
    "\n",
    "$$\n",
    "    \\mathbf{H}\\mathbf{a} = \\mathbf{d}\n",
    "$$\n",
    "\n",
    "> where \n",
    "\n",
    "$$\n",
    "\\begin{array}{ll}\n",
    "\\mathbf{a} & = & {(a_0, a_1, a_2, \\cdots , a_n)}^T \\\\\n",
    "\\mathbf{d} & = & {(d_0, d_1, d_2, \\cdots , d_n)}^T \\\\\n",
    "d_k & = & (f,\\varphi_k) \\space \\space , \\space \\space (k=0,1,\\cdots, n)\n",
    "\\end{array}\n",
    "$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ab082410",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
